<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <#include "/back/common.html">
    <!--<link rel="stylesheet" href="/back/layui/css/layui.css">-->
    <!--<link rel="stylesheet" href="/zTree/css/zTreeStyle/zTreeStyle.css" type="text/css">-->
    <!--<script src="/back/js/jquery.min.js"></script>
    <script src="/back/layui/layui.js"></script>-->
    <!--<script type="text/javascript" src="/zTree/js/jquery.ztree.all.js"></script>-->
    <!--<script type="text/javascript" src="/js/myTree.js"></script>-->
</head>
<body>

<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
    <legend>商品一级分类信息</legend>
</fieldset>

<form class="layui-form" id="userForm">
    <input type="hidden" id="pk" name="pk" value="${mv.pk}">
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label"><font color="red">※</font>一级分类名称</label>
            <div class="layui-input-inline">
                <select class="layui-select" id="productTypeParent" name="productTypeParent" lay-search="productTypeParent" lay-verify="notNull">
                    <option value="-1" >输入一级分类名称搜索</option>
                    <#if firstProductTypeList?? && firstProductTypeList?size &gt;0>
                        <#list firstProductTypeList as item>
                            <tr>
                                <option value="${item.pk}">${item.product_type_name}</option>
                            </tr>
                        </#list>
                    </#if>
                </select>
                <script>
                    $("#productTypeParent").val("${mv.product_type_parent}");
                </script>
            </div>
        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label"><font color="red">※</font>二级分类名称</label>
            <div class="layui-input-inline">
                <input type="text" name="productTypeName"  id="productTypeName" value="${mv.product_type_name}"
                       lay-verify="notNull" autocomplete="off"
                       class="layui-input">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label"><font color="red">※</font>二级分类编码</label>
            <div class="layui-input-inline">
                <input type="text" name="productTypeCode" id="productTypeCode" value="${mv.product_type_code}" lay-verify="notNull" autocomplete="off"
                       class="layui-input">
            </div>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">描述</label>
            <div class="layui-input-inline">
                <input type="text" name="productDesc" id="productDesc" value="${mv.product_desc}" lay-ignore="true" autocomplete="off"
                       class="layui-input">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">备注</label>
            <div class="layui-input-inline">
                <input type="text" name="no1" id="no1" value="${mv.no1}" autocomplete="off"
                       class="layui-input">
            </div>
        </div>
    </div>

    <div class="layui-form-item" style="text-align: center">
        <div class="layui-input-block">
            <button class="layui-btn layui-btn-normal layui-btn-radius" lay-submit="" lay-filter="demo1">立即提交</button>
            <!--<button class="layui-btn layui-btn-primary layui-btn-radius" type="reset">重置</button>-->
        </div>
    </div>
</form>
<script>
    layui.use(['form', 'layedit', 'laydate'], function () {
        var form = layui.form
            , layer = layui.layer
            , layedit = layui.layedit
            , laydate = layui.laydate;
        form.render();
        //日期
        /*laydate.render({
            elem: '#birthday'
        });*/


        //自定义验证规则
        /*form.verify({
            title: function (value) {
                if (value.length < 5) {
                    return '标题至少得5个字符啊';
                }
            },
            notNull: function (value) {
                if (value.length <= 0) {
                    return '信息必填';
                }
            }
            , password: [
                /^[\w_-]{6,16}$/
                , '密码必须6到12位，且不能出现空格'
            ]
            , email: [
                /^[a-zA-Z0-9_.-]+@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*\.[a-zA-Z0-9]{2,6}$/
                , '密码必须6到12位，且不能出现空格'
            ]
            , phone: [
                /^[1][2,3,4,5,6,7,8,9][0-9]{9}$/
                , '手机号码格式异常'
            ]
            , account: [
                /^[A-Za-z0-9]{4,16}$/
                , '请输入4位以上的英文或数字组合'
            ]
            , content: function (value) {
                layedit.sync(editIndex);
            }
        });*/

        //监听提交
        form.on('submit(demo1)', function (data) {
            layui.use(['jquery'], function () {
                var $ = jQuery = layui.$;
                var postUrl = "/productType/saveOrUpdate";
                $.ajax({
                    url: postUrl,
                    type: 'post',
                    data: $("#userForm").serialize(),
                    success: function (resp) {
                        $("#formId").val(resp.data);
                        layer.msg(resp.message);
                        parent.layer.close(parent.layer.getFrameIndex(window.name));
                        parent.initTable();//刷新表格数据
                    },
                    error: function (resp) {
                        layer.msg(resp.message);
                    }
                });
            });
            return false;
        });
    });
</script>

</body>
</html>